package thread.syn;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

@Slf4j
public class WaitAndNotify {

    @Test
    public void test() {

        Object syno = new Object();

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (syno) {
                    log.info("start");

                    try {
                        syno.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    syno.notify();

                    log.info("end");
                }
            }
        });
        thread.start();
        try {
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
